package cn.zjutleo.village_server.service;

import cn.zjutleo.village_server.dto.PUStarandcolletKeyDto;
import cn.zjutleo.village_server.entity.PUStarandcollet;
import cn.zjutleo.village_server.entity.PUStarandcolletKey;
import cn.zjutleo.village_server.mapper.PUStarandcolletMapper;
import cn.zjutleo.village_server.vo.PUStarandColletVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PUStarandcolletService {
    @Resource
    private PUStarandcolletMapper pustarandcolletMapper;


    /**
     * 判断是否已经有这个用户和政策的关联信息
     * @param puStarandcolletKeyDto
     * @return
     */
    public boolean isContainPU(PUStarandcolletKeyDto puStarandcolletKeyDto){
        PUStarandcolletKey puStarandcolletKey =new PUStarandcolletKey();
        BeanUtils.copyProperties(puStarandcolletKeyDto,puStarandcolletKey);
        PUStarandcollet puStarandCollet = pustarandcolletMapper.selectByPrimaryKey(puStarandcolletKey);
        if(puStarandCollet!=null)return true;
        else return false;
    }

//    public boolean isContainPU(PUStarandcolletKeyDto puStarandcolletKeyDto){
//        PUStarandcolletKey puStarandcolletKey = new PUStarandcolletKey();
//        BeanUtils.copyProperties(puStarandcolletKeyDto,puStarandcolletKey);
//        PUStarandcollet puStarandCollet=pustarandcolletMapper.selectByPrimaryKey(puStarandcolletKey);
//        if(puStarandCollet!=null) return true;
//        else return false;
//    }
    public void insert(PUStarandcollet puStarandcollet){
        pustarandcolletMapper.insert(puStarandcollet);
    }

    public void update(PUStarandcollet puStarandcollet){
        pustarandcolletMapper.updateByPrimaryKeySelective(puStarandcollet);
    }

}
